import Vue from 'vue'
import App from './App'
import track from '@/modules/track'
import { config, http } from './config/conifg'
import * as utils from './utils/index'
import store from './modules/store/store'
import api from '@/modules/api/index'
import TrackingMixin from '@/modules/mixins/tracking'

import XrNavBar from './components/common/xr-nav-bar'
import XrPopup from './components/common/xr-popup'
import XpModal from './components/common/xp-modal'
import GetPhoneNumber from './components/common/get-phone-number'
import IosPayPrompt from './components/common/iso-pay-prompt'
import Feedback from './components/common/feedback'

Vue.component('xr-nav-bar', XrNavBar)
Vue.component('xr-popup', XrPopup)
Vue.component('xp-modal', XpModal)
Vue.component('get-phone-number', GetPhoneNumber)
Vue.component('iso-pay-prompt', IosPayPrompt)
Vue.component('feedback', Feedback)

const flux = {
  track,
  config,
  utils,
  http,
  $api: api,
  store,
  reject: Promise.reject.bind(Promise),
  resolve: Promise.resolve.bind(Promise),
  all: Promise.resolve.bind(Promise)
}

uni.flux = flux

Vue.config.productionTip = false
App.mpType = 'app'

Vue.prototype.$api = api

uni.flux.isLogin = new Promise(resolve => {
  uni.flux.isLogined = resolve
})

Vue.mixin(TrackingMixin)

// #ifdef H5
Vue.config.ignoredElements.push('wx-open-launch-weapp')
// #endif

const app = new Vue({
  store,
  ...App
})
app.$mount()

// #ifdef MP-WEIXIN
wx.flux = flux
// #endif

// #ifdef H5
window.flux = flux
// #endif
